/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */
#pragma once

#include <stddef.h> // for wchar_t - URODI
#include <string>
#include <Utf8String.h>

namespace liba
{
namespace xml
{

class Provider;
class SaverBase;
class ObjectANSI;
class ObjectUnicode;

template<class Sym>
class Saver;


class Object
{
public://BUG
	ObjectANSI * ansi_object;
	ObjectUnicode * unicode_object;
public:
	Object():
		ansi_object( 0 ),
		unicode_object( 0 )
	{}
	bool on_base_node( Provider * prov, const std::string & name );
	bool on_base_node( Provider * prov, const std::wstring & name );
	bool on_base_node( Provider * prov, const Utf8String & name );
	bool on_base_attribute( Provider * prov, const std::string & name, const std::string & value );
	bool on_base_attribute( Provider * prov, const std::wstring & name, const std::wstring & value );
	bool on_base_attribute( Provider * prov, const Utf8String & name, const Utf8String & value );

	void operator=(const Object & obj)
	{
		//do nothing
	}

	virtual bool on_end_node( Provider * prov )
	{
		return true; // Most objects do not need this behavior
	}
	virtual bool on_data( Provider * prov, const void * data, unsigned size )
	{
		return false;
	}
	virtual void on_save_attributes( SaverBase * saver )const
	{}
	virtual void on_save_nodes( SaverBase * saver )const
	{}
	virtual void on_save_data( SaverBase * saver )const
	{}
};

class EndNodeProxy : public Object
{
public:
	explicit EndNodeProxy( Object * obj )
	{
		ansi_object = obj->ansi_object;
		unicode_object = obj->unicode_object;
	}
};

class ObjectANSI : virtual public Object
{
public:
	ObjectANSI()
	{
		ansi_object = this;
	}
	ObjectANSI(const ObjectANSI & obj)
	{
		ansi_object = this;
	}
	virtual bool on_node( Provider * prov, const std::string & name )
	{
		return false;
	}
	virtual bool on_attribute( Provider * prov, const std::string & name, const std::string & value )
	{
		return false;
	}
};

class ObjectUnicode : virtual public Object
{
public:
	ObjectUnicode()
	{
		unicode_object = this;
	}
	ObjectUnicode(const ObjectUnicode & obj)
	{
		unicode_object = this;
	}
	virtual bool on_node( Provider * prov, const std::wstring & name )
	{
		return false;
	}
	virtual bool on_attribute( Provider * prov, const std::wstring & name, const std::wstring & value )
	{
		return false;
	}
};

} // namspace xml
} // namspace liba

using namespace liba;

